CREATE PROCEDURE [WriteLog] 
( 
    @EventID int, 
    @Priority int, 
    @Title nvarchar(256), 
    @MachineName nvarchar(32), 
    @AppDomainName nvarchar(512), 
    @ThreadName nvarchar(512), 
    @Message nvarchar(1500), 
    @LogId int OUTPUT 


) 
AS

    INSERT INTO [Log] ( 
        EventID, 
        Priority, 
        Title, 
        MachineName, 
        AppDomainName, 
        ThreadName, 
        Message) 
    VALUES ( 
        @EventID, 
        @Priority, 
        @Title, 
        @Timestamp, 
        @MachineName, 
        @AppDomainName, 
        @ThreadName, 
        @Message)

    SET @LogID = @@IDENTITY 
    RETURN @LogID

ALTER TABLE [CategoryLog]  WITH CHECK ADD  CONSTRAINT [FK_CategoryLog_Category] FOREIGN KEY(    [CategoryID]) 
REFERENCES [Category] (    [CategoryID]) 
ALTER TABLE [CategoryLog]  WITH CHECK ADD  CONSTRAINT [FK_CategoryLog_Log] FOREIGN KEY(    [LogID]) 
REFERENCES [Log] (    [LogID])